home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-24 | 3.4 KB | 116 lines | [TEXT/KAHL] |
- /******************************************************************************
- CAMPopupPane.c
-
-
- Like the StdPopupPane class that it overrides, except that font, size and
- style can be set from an 'APop' resource.
-
- SUPERCLASS = CStdPopupPane
-
- Copyright © 1991 Bowers Development Corporation. All rights reserved.
-
- ******************************************************************************/
-
- #include <Sound.h>
- #include "CAMPopupMenu.h"
- #include "CAMPopupPane.h"
-
- /******************************************************************************
- IViewTemp
-
- Initialize a PopupPane using a template
-
- ******************************************************************************/
- void CAMPopupPane::IViewTemp (CView *anEnclosure,
- CBureaucrat *aSupervisor,
- Ptr viewData)
- {
- register AMPopupTempP p;
-
- p = (AMPopupTempP) viewData;
- saveTypeStyleP = &p->typeStyle;
- inherited::IViewTemp (anEnclosure, aSupervisor, (Ptr)&p->sStdPopupTemp);
-
- } /* IViewTemp */
-
- /******************************************************************************
- MakePopupMenu {OVERRIDE}
-
- Creates the PopupMenu owned by the PopupPane. Override to create
- a subclass of CPopupMenu.
- ******************************************************************************/
-
- void CAMPopupPane::MakePopupMenu (short menuID,
- Boolean fAutoSelect,
- Boolean fMultiSelect)
- {
- CAMPopupMenu *aMenu;
- short fontNum;
-
- fontNum = AMGetFontNum (saveTypeStyleP->fontName);
-
- aMenu = new CAMPopupMenu;
- aMenu->IAMPopupMenu (menuID, this, fAutoSelect, fMultiSelect,
- fontNum,
- saveTypeStyleP->textSize);
- itsMenu = aMenu;
-
- } /* MakePopupMenu */
-
- /******************************************************************************
- CalcDimensions {OVERRIDE}
-
- If this is the first time through (the "saveViewData" pointer isn't NIL)
- then set the font, size and style instance variables. Otherwise, just
- call the inherited method.
- This is being done to make sure that font, size and style are correct
- before CalcDimensions is called the first time.
-
- ******************************************************************************/
- void CAMPopupPane::CalcDimensions (void)
- {
- if (saveTypeStyleP != nil) { /* first time through */
- textFont = AMGetFontNum (saveTypeStyleP->fontName);
- textSize = saveTypeStyleP->textSize;
- saveTypeStyleP = nil;
- }
- inherited::CalcDimensions ();
-
- } /* CalcDimensions */
-
- /******************************************************************************
- NewMenuSelection {OVERRIDE}
-
- Receive notification of a new menu selection. Broadcast the change
- to our supervisor.
- ******************************************************************************/
-
- void CAMPopupPane::NewMenuSelection (short itemSelected)
- {
- BroadcastChange (popupMenuNewSelection, &itemSelected);
-
- inherited::NewMenuSelection (itemSelected);
-
- } /* NewMenuSelection */
-
- /******************************************************************************
- PlaySound
-
- For a "Sounds" menu: play the sound named by the itemNr.
- ******************************************************************************/
-
- void CAMPopupPane::PlaySound (short itemNr)
- {
- Str255 soundName;
- Handle sound;
- OSErr errCode;
-
- GetItem (itsMenu->GetMacMenu (), itemNr, soundName);
- sound = GetNamedResource ('snd ', soundName);
- if (sound != NULL) {
- errCode = SndPlay (NULL, sound, false);
- }
- } /* PlaySound */
-
- /* CAMPopupPane */
-